﻿using System.Diagnostics;
using System.Reflection;
using System.Windows;
using System.Windows.Input;

using Labthink.PCSoft.UniversalHost4.Utility;
using MouseEventArgs = System.Windows.Input.MouseEventArgs;

namespace Labthink.PCSoft.UniversalHost4
{
    public partial class About
    {
        public About()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var version = States.Instance.DeviceVersion;
            if (string.IsNullOrEmpty(version))
            {
                TxtDeviceVersionTitle.Visibility = Visibility.Collapsed;
                TxtDeviceVersion.Visibility = Visibility.Collapsed;
            }
            else
            {
                TxtDeviceVersion.Text = $"{version}";
            }

            var v = Common.BaseInfo.Version;
            if (string.IsNullOrEmpty(v))
            {
                TxtSoftVersionTitle.Visibility = Visibility.Collapsed;
            }
            else
            {
                TxtSoftVersion.Text = v;
            }

            Top = (SystemParameters.FullPrimaryScreenHeight - Height) / 2;
            Left = (SystemParameters.FullPrimaryScreenWidth - Width) / 2;
        }

        private void WebNet_Click(object sender, RoutedEventArgs e)
        {
            Process.Start(new ProcessStartInfo(LanguageManager.GetLanguageValue("WebNet")));
        }

        private void EMail_Click(object sender, RoutedEventArgs e)
        {
            Process.Start(new ProcessStartInfo("mailto:" + LanguageManager.GetLanguageValue("EMail")));
        }

        private void About_OnMouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed) DragMove();
        }

        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }
}
